package com.eastmoney.emis.edda.infrastructure.report;

import com.eastmoney.emis.utils.common.enums.ApplicationStatus;
import com.eastmoney.emis.utils.common.exception.BusinessException;

import java.text.MessageFormat;

public enum ReportType {

    DDAReport(1, "dda"),

    DDIReport(2, "ddi");

    private int id;
    private String value;

    private static final ReportType[] REPORT_TYPES;

    static {
        REPORT_TYPES = ReportType.values();
    }

    ReportType(int id, String value) {
        this.id = id;
        this.value = value;
    }

    public int getId() {
        return id;
    }

    public String getValue() {
        return value;
    }

    public static ReportType parse(String value) {
        for (ReportType reportType : REPORT_TYPES) {
            if (reportType.value.equals(value)) {
                return reportType;
            }
        }
        throw new BusinessException(ApplicationStatus.ILLEGAL_ARGUMENT_EXCEPTION);
    }

    public String formatFileName(String date) {
        return MessageFormat.format("{0}-{1}", this.name(), date);
    }


}
